package com.crm.service.impl.orderManager;

import com.crm.dao.mapper.orderManager.CustomerOrderActivityRelationMapper;
import com.crm.model.entity.orderManager.CustomerOrderActivityRelation;
import com.crm.model.entity.orderManager.CustomerOrderActivityRelationExample;
import com.crm.service.orderManager.CustomerOrderActivityRelationDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author luojie
 * @date 2021/3/25 15:40
 */
@Service
public class CustomerOrderActivityRelationDbServiceImpl implements CustomerOrderActivityRelationDbService {

    @Autowired
    CustomerOrderActivityRelationMapper orderActivityRelationMapper;

    @Override
    public Boolean insert(CustomerOrderActivityRelation customerOrderActivityRelation) {
        int num = orderActivityRelationMapper.insert(customerOrderActivityRelation);
        return num>0;
    }

    @Override
    public List<CustomerOrderActivityRelation> selectOrderActivityRelationByOrderIdAndActivityId(String orderId, String activityId) {
        CustomerOrderActivityRelationExample customerOrderActivityRelationExample = new CustomerOrderActivityRelationExample();
        CustomerOrderActivityRelationExample.Criteria criteria = customerOrderActivityRelationExample.createCriteria();
        criteria.andProductOrderIdEqualTo(orderId);
        criteria.andProductActivityIdEqualTo(activityId);
        List<CustomerOrderActivityRelation> orderActivityRelationList = orderActivityRelationMapper.selectByExample(customerOrderActivityRelationExample);
        return orderActivityRelationList;
    }

}
